package com.yyaccp.appinfo.service;

import com.yyaccp.appinfo.domain.BackendUser;
import com.yyaccp.appinfo.exception.LoginException;
import com.yyaccp.appinfo.mapper.BackendUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class BackendUserService {
    @Autowired
    private BackendUserMapper backendUserMapper;

    public BackendUser login(BackendUser user) throws LoginException {
        BackendUser admUser = backendUserMapper.selectByuserCode(user.getUserCode());
        if(admUser == null){
            throw new LoginException("用户不存在");
        }
        if(!admUser.getUserPassword().equals(user.getUserPassword())){
            throw new LoginException("密码不正确");
        }
        return admUser;
    }
}
